<template>
  <div v-show="isShow" class="calling-api-center">
    <div class="caller-body">
      <div class="voice-text">{{ msgContent.voiceText }}</div>
    </div>
  </div>
</template>

<script>
import mitts from '@/utils/mitt';

export default {
  name: 'msgWin',
  data() {
    return {
      isShow: false,
      msgId: '',
      msgContent: {
        voiceCall: '',
        voiceText: ''
      }
    };
  },
  mounted() {
    mitts.on('openMsgWins', this.dealMsgWin);
    mitts.on('closeWins', this.closeMsgWin);
  },
  methods: {
    closeMsgWin() {
      this.isShow = false;
      this.$AndroidSdk.writeLog('收到关闭弹窗---->');
    },
    handlerLimited(arr, max) {
      arr = arr || [];
      return arr.slice(0, max);
    },
    // 处理消息窗口
    dealMsgWin(obj) {
      this.$AndroidSdk.writeLog('收到开启弹窗---->' + JSON.stringify(obj));
      try {
        let msgContent = JSON.parse(obj.msgContent);
        this.msgId = obj.msgId;
        this.msgContent.voiceText = msgContent.voiceText || '';
        this.msgContent.voiceCall = msgContent.voiceCall || '';
        this.isShow = true;
      } catch (e) {
        this.$AndroidSdk.writeLog('dealMsgWin---->' + e.message);
      }
    }
  }
};
</script>
<style scoped lang="scss">
@import '@/assets/styles/wait.scss';
</style>
